package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.MyMoneyType;
import com.sl.au.repository.MyMoneyTypeRepository;
import com.sl.au.service.MyMoneyTypeService;
@Service("MyMoneyTypeService")
@Transactional
public class MyMoneyTypeServiceImpl implements MyMoneyTypeService{
	
	@Autowired
	MyMoneyTypeRepository myMoneyTypeRepository;
	
	@Override
	public MyMoneyTypeRepository getRepository() {
		// TODO Auto-generated method stub
		return this.myMoneyTypeRepository;
	}

	@Override
	public List<MyMoneyType> getMoneyType(int start, int size, String id) {
		// TODO Auto-generated method stub
		Page<MyMoneyType> pages = null;
		Pageable pageable = new PageRequest(start / size, size, Sort.Direction.DESC, "createTime");
		pages = myMoneyTypeRepository.getMoneyType(id, pageable);
		return pages.getContent();
	}

	@Override
	public long getCount(String id) {
		long count = myMoneyTypeRepository.getCount(id);
		return count;
	}

}
